#!/bin/bash
#脚本运行命令：./kube.proxy.sh 192.168.1.206
NODE_ADDRESS=${1:-"192.168.1.206"}

cat <<EOF >/usr/local/kubernetes/cfg/kube-proxy

KUBE_PROXY_OPTS="--logtostderr=true \
--v=4 \
--proxy-mode=ipvs \
--hostname-override=${NODE_ADDRESS} \
--kubeconfig=/usr/local/kubernetes/ssl/kube-proxy.kubeconfig"

EOF

cat <<EOF >/usr/lib/systemd/system/kube-proxy.service
[Unit]
Description=Kubernetes Proxy
After=network.target

[Service]
EnvironmentFile=-/usr/local/kubernetes/cfg/kube-proxy
ExecStart=/usr/local/kubernetes/bin/kube-proxy \$KUBE_PROXY_OPTS
Restart=on-failure

[Install]
WantedBy=multi-user.target
EOF

systemctl daemon-reload
systemctl enable kube-proxy
systemctl restart kube-proxy
